#pragma once
#include <queue>
#include "ECS/ECS.h"
#include "../TaskSystem/Task.h"

using tasksystem::Task;
class TaskPerformer : public ECS::Component
{
	mtMETA_DEC;
public:
	TaskPerformer();
	virtual ~TaskPerformer();

	bool hasTask() const;

	void addTask(Task* task, bool startImmediately = true);

	Task* getCurrentTask() const;

	void onUpdate();

	Signal<void(Task*)> eventTaskStarted;
	Signal<void(Task*)> eventTaskDone;
	Signal<void(Task*)> eventTaskInterrupted;
	Signal<void(Task*)> eventTaskFinilized;
protected:
	void update(float dt);

	Task* _currentTask;
	std::queue<Task*> _taskQueue;

};